//
//  LoveTimesCollectionViewCell.m
//  safeLady
//
//  Created by Justsoso on 2017/7/11.
//  Copyright © 2017年 xmy. All rights reserved.
//

#import "LoveTimesCollectionViewCell.h"

@implementation LoveTimesCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        UIView *view = self.contentView;
        int radHeight = arc4random()%100;
        CGFloat height = H(radHeight) == 0 || H(radHeight) > W(8) ? H(radHeight) : W(8);
        self.dataView = [[UIView alloc] init];
        self.dataView.cornerRadius = W(8) / 2;
        self.dataView.backgroundColor = [UIColor gradientFromColor:[UIColor colorWithHex:0x9396B1] toColor:[UIColor colorWithHex:0xDBDBE4] withHeight:height + 1];
        [self.contentView addSubview:self.dataView];
        [self.dataView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(W(8)));
//            make.left.equalTo(view.mas_left);
            make.centerX.equalTo(view.mas_centerX);
            make.bottom.equalTo(view.mas_bottom).offset(H(-50));
            make.height.equalTo(@(height));
        }];
        
        self.dateLabel = [[UILabel alloc] init];
        self.dateLabel.text = @"29/7";
        self.dateLabel.font = [UIFont systemFontOfSize:H(10.f)];
        self.dateLabel.textColor = [UIColor colorWithHex:0xC1BFBF];
        [self.contentView addSubview:self.dateLabel];
        [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.dataView.mas_centerX);
            make.height.equalTo(@H(10));
            make.top.equalTo(self.dataView.mas_bottom).offset(5);
        }];
        
        self.timeLabel = [[UILabel alloc] init];
        self.timeLabel.text = @"12:20";
        self.timeLabel.font = [UIFont systemFontOfSize:H(8.f)];
        self.timeLabel.textColor = [UIColor colorWithHex:0xC1BFBF];
        [self.contentView addSubview:self.timeLabel];
        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.dataView.mas_centerX);
            make.height.equalTo(@H(8));
            make.top.equalTo(self.dateLabel.mas_bottom).offset(3);
        }];
        
        
        
    }
    return self;
}

- (void)setDataViewHeight:(CGFloat)dataViewHeight {
    
    self.dataView.backgroundColor = [UIColor gradientFromColor:[UIColor colorWithHex:0x9396B1] toColor:[UIColor colorWithHex:0xDBDBE4] withHeight:dataViewHeight + 1];
    [self.dataView mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.height.equalTo(@(dataViewHeight));
    }];
}

- (void)setDataViewWidth:(CGFloat)dataViewWidth {
    [self.dataView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(dataViewWidth));
    }];
}

@end
